package com.keba.lamp.ai.controller;


import com.keba.basic.base.R;
import com.keba.lamp.ai.strategy.ApiCallStrategy;
import com.keba.lamp.ai.vo.query.AiCallModelQuery;
import com.keba.lamp.ai.vo.query.AiCallModelRequestQuery;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/anyTenant/aiApiCall")
@Tag(name = "Ai Api 调用管理")
public class AiApiCallController {

    private final ApiCallStrategy apiCallStrategy;


    @PostMapping("/")
    @Operation(summary = "Ai 模型调用", description = "Ai 模型调用")
    public R<Object> call(@RequestBody AiCallModelRequestQuery aiCallModelQuery) {
        return R.success(apiCallStrategy.call(aiCallModelQuery));
    }

    @GetMapping("/test")
    public R<Object> testCall(AiCallModelRequestQuery aiCallModelQuery) {

        List<AiCallModelRequestQuery.CompletionContent> completionContentList = new ArrayList<>();
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/7b2f5a35f14c44b883a523fea4f91859.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/b715150588e44b508ab6b73921fc2da5.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/2c78cb7df6b542fd83fc6445bc8544b8.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/7f404fc8c38843e58379c57f32f2d1c5.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/7e76936372664d99a099376e9804c7e2.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/ae14e09ce87f428095d0d1b724d9b50d.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/3e47d6fcfaa54698a1a3a7b1ea2ebd3d.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/cc20034166234e8ba3a8a050e8946b4f.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/e7bd59f650424152831da7ab5d1c3851.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/ecd840913eb441b3b5a3203d706defdd.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/a44748c4e18f42c0a7d16c83adb16291.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/f93bfc3a48bc4f32aeee7f800cce4fc1.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/590e5d66482d469bb1c7895c8a8caa82.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/dd12a5d4469d4eb7917e72a6bdc05de3.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/96e7fc5f468b419e95735ff4dd123916.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/d5911b72f5ae4b56b8fe5fda0d5b7fa9.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/9c187ddfb7f44e108332d25767103aca.jpg").build());
        completionContentList.add(AiCallModelRequestQuery.CompletionContent.builder().type("image_url").fileUrl("https://michi-product.oss-cn-shanghai.aliyuncs.com/626750571617821721/COMPLAINT__EVIDENCE__FILE/2025/05/23/c095152d93844900acda1f655fac7375.jpg").build());
        aiCallModelQuery.setCompletionContents(completionContentList).setAppId(612648308494091618L)
                .setAppKey("3f365fd74e654a9cbdf29dc04406e0b8").setBizId("12222222");
        return R.success(apiCallStrategy.call(aiCallModelQuery));
    }

}
